const keyword = {


    // 请求屏蔽关键字
    getKeyWord: function (token,callback) {
        this.public('/home/keywordShields/read?token='+token,callback);
    },
    //公共请求的function
    public: function (methods, success, error) {
        let xhr = new XMLHttpRequest();
        let formData = new FormData();
        xhr.open("get", process.env.API_URL + methods);
        xhr.send(formData);
        xhr.onreadystatechange = function () {
            if (xhr.status === 200) {
                if (xhr.readyState === 4) {
                    let responseData = JSON.parse(xhr.responseText);
                    if (success) success(responseData);
                }
            } else {
                if (errorHandler) {
                    let responseData = JSON.parse(xhr.responseText);
                    if (error) error(responseData);
                } else {
                    alert("请求失败！" + xhr.responseText);
                }
            }
        };
    }
}


export default keyword;